import { Navigate } from 'react-router-dom'
import Login from '@/pages/Login'
import Home from '@/pages/Home/'
import Grades from '@/pages/Home/Grade'
import UserInfor from '@/pages/Home/UserInfor'
import Course from '@/pages/Home/Course'
import TrainingPlan from '@/pages/Home/TrainingPlan'

import StudentStatus from '@/pages/Home/StudentStatus'
import Announcement from '@/pages/Home/Announcement'
import Examination from '@/pages/Home/Examination'
import Curriculum from '@/pages/Home/Curriculums'
import StudentInfors from '@/pages/Home/StudentInfors'
import NotFound from '@/components/NotFound'


export default function useRoutingPermissions(role) {

  const teacherRoutes = [
    { path: "userInfor", element: <UserInfor /> },
    { path: "course", element: <Course /> },
    { path: "trainingPlan", element: <TrainingPlan /> },
    { path: "grades", element: <Grades /> },
    { path: "examination", element: <Examination /> },
    { path: "studentStatus", element: <StudentStatus /> },
    { path: "announcement", element: <Announcement /> },
    { path: "curriculum", element: <Curriculum /> }, //教师权限所属的界面
    { path: "studentInfors", element: <StudentInfors /> }
  ]
  const studentRoutes = [
    { path: "userInfor", element: <UserInfor /> },
    { path: "course", element: <Course /> },
    { path: "trainingPlan", element: <TrainingPlan /> },
    { path: "grades", element: <Grades /> },
    { path: "examination", element: <Examination /> },
    { path: "studentStatus", element: <StudentStatus /> },
    { path: "announcement", element: <Announcement /> },
  ]

  const  routes = [
    {
      path: "*",
      element: <NotFound ></NotFound>,
    },
    {
      path: '/',
      element: <Navigate to='/login' replace={true}></Navigate>
    },
    {
      path: "/login",
      element: <Login />
    },
    {
      path: "/home",
      element: <Home></Home>,
      children: role?.fd_type === "student" ? studentRoutes :role?.fd_type === "teacher" ?teacherRoutes:[]
    }
  ]

  return routes
}
